package com.wy.oauth2;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

@Configuration
@EnableResourceServer
public class MyResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter {

	@Override
	public void configure(HttpSecurity http) throws Exception {
		http.
		authorizeRequests()
		.antMatchers("/usernamepassword/token",
				"/residences/all",//获取所有小区的接口
				"/save_building",//保存楼栋信息接口
				"/get_building_list",//查询楼栋信息接口
				"/buildings/buildingByRid",//根据小区id获取楼栋信息接口
				"/save_house",//保存房屋信息接口
				"/get_house_list",//查询房屋信息接口
				"/getHouseByBuildingId",//根据楼栋id获取房屋信息的接口
				"/save_household",//保存业主信息接口
				"/get_household_list",//查询业主信息接口
				"/households/uploadImg/**",//上传图片接口
				"/users/register",//用户注册信息接口
				"/test1",
				"/residences/**",
				"/households/register",
				"/getHouseByBuildingId",
				"/v2/api-docs",
				"/doc.html",
				"/webjars/**",
				"/residences/residenceTree",
				"/residences/download",
				"/residences/import",
				"/residences/residenceTree",
				"/test/**",
				"/repairs/**",
				"/buildings/download",
				"/buildings/import",
				"/houses/import",
				"/houses/download",
				"/households/download",
				"/households/import",
				"/fee/generate",
				"/app/getQR",
				"/clearImg",
				"/houses/getUnitByBuildingId",
				"/houses/getHousesByBidUnit"

		).permitAll()
//		.antMatchers().hasRole("ADMIN")
//		.antMatchers("/users/**","/menus/**","/roles/**","/households/**").hasRole("ADMIN")
//		.antMatchers("/users/**","/menus/**","/roles/**","/households/**").hasRole("APP")
		.anyRequest()
		.authenticated();
	}

}
